{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import os\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "###statistic\n",
    "for i in [1,2,3]:\n",
    "    wdata = pd.read_csv('Weather Data/W'+str(i)+'.csv')\n",
    "    STA_all = wdata.describe(include = 'all') ###all types data\n",
    "    STA = pd.DataFrame(index = wdata.columns[[1,2,3,5,6,7]], columns = ['Mean','Standard deviation','Skew','Kurtosis',\\\n",
    "    '0th percentile','2.5th percentile','50th percentile','97.5th percentile','100th percentile'],dtype = 'float')\n",
    "    for c in wdata.columns[[1,2,3,5,6,7]]:\n",
    "        STA.loc[c,'Mean'] = wdata[c].mean(axis=0)\n",
    "        STA.loc[c,'Standard deviation'] = round(wdata[c].std(axis=0),2)\n",
    "        STA.loc[c,'Skew'] = wdata[c].skew(axis=0)\n",
    "        STA.loc[c,'Kurtosis'] = wdata[c].kurtosis(axis=0)\n",
    "        STA.loc[c,'0th percentile'] = wdata[c].quantile(q=0)\n",
    "        STA.loc[c,'2.5th percentile'] = wdata[c].quantile(q=0.025)\n",
    "        STA.loc[c,'50th percentile'] = wdata[c].quantile(q=0.5)\n",
    "        STA.loc[c,'97.5th percentile'] = wdata[c].quantile(q=0.975)\n",
    "        STA.loc[c,'100th percentile'] = wdata[c].quantile(q=1)#np.round(,2)\n",
    "    STA_nonnum = wdata.iloc[:,[4,8]].describe() ###4 statistics for non-num data #count,unique,top,freq(for top)\n",
    "    STA = STA.round(2)\n",
    "    # df.round({'dogs': 2})\n",
    "    STA_all = STA_all.T.round(2)\n",
    "    STA_nonnum = STA_nonnum.T.round(2)\n",
    "    STA.to_csv('process result/num_sta_W'+str(i)+'.csv')\n",
    "    STA_nonnum.to_csv('process result/nonnum_sta_W'+str(i)+'.csv')\n",
    "    STA_all.to_csv('process result/all_sta_W'+str(i)+'.csv')\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
